
<include file="App/Home/View/Public/header.html" />
<div id="account-main" role="main">
	<div class="container account-content">
		<div class="row">
			<include file="App/Home/View/Public/left.html" />
			<div class="col-xs-9 account-right">
				<div id="coin-withdraw">
					<h1 class="title">{$cuid.currency_name}提币</h1>
					<div id="coin-withdraw-address">
						<h2 class="form-title">选择一个提币地址</h2>
						<div class="blue-wrap blue-border">
							<table id="card-chose">
								<thead>
									<tr>
										<th>选择</th>
										<th>地址标签</th>
										<th>提币地址</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<volist name="address" id="vo" key="k">	
										<tr align="center">
										  <td><input type="radio" value="{$vo.id}" id="address_id" name="redios" onclick="address_id($(this))" <eq name="k" value="1">checked="checked"</eq>></td>
						                  <td><input class="sum"   type="text"  value="{$vo.name|default=''}" disabled="disabled"></td>
										  <td><input class="sum"  style="width:300px;"  type="text"  disabled="disabled"  value="{$vo.qianbao_url|default=''}"></td>
						                  <td><a class="link-del" href="{:U('Pay/del_address',array('id'=>$vo['id'],'cuid'=>$cuid['currency_id']))}">删除</a></td>
										</tr>
									</volist>
								</tbody>
							</table>
						</div> 
						<form id="addressForm"  jump-url="{:U('Pay/tcoin',array('currency_id'=>$cuid['currency_id']))}" method="post" action="{:U('Pay/add_qianbao_address')}" method="post" >
								<input type="hidden" name="currency_id" value="{$cuid['currency_id']}" />
							<section class="address-confirm" hidden="" style="display: none;">
								<label for="label" style="width: 140px;">新地址</label> <input
									name="name"
									class="form-control address-margin" data-val="true"
									data-val-length="The field 例如：张三的地址 must be a string with a maximum length of 100."
									data-val-length-max="100" data-val-required="地址标签不能为空"
									id="Label" name="Label" placeholder="例如：张三的地址" type="text"
									value=""> 
									<input class="form-control address-input"
									data-val="true"
									data-val-length="The field 例如：1DwunA9otZZQyhkVvkLJ8DV1tuSwMF7r3v must be a string with a maximum length of 100."
									data-val-length-max="100" data-val-required="提币地址不能为空"
									id="Address"  
									placeholder="例如：1DwunA9otZZQyhkVvkLJ8DV1tuSwMF7r3v" type="text"
									value="" name="address" >
									<button type="submit" class="btn btn-primary">确定提交</button>
							</section>
							<section class="add-address">
								<a id="addAddress" class="add"
									href="?marketCoinId=DWC#"><span></span>
									添加一个新的提币地址</a>
							</section>
						</form>
					</div>
					<h2 class="form-title">
						输入要提币的数额 <small> （可用余额：<span class="amount">{$cuser.num}
						</span><span class="type"> {$cuid.currency_mark}</span>）
						</small>
					</h2>

					<div id="withdrawDiv" class="blue-wrap">
						<form jump-url="{:U('Pay/tcoin',array('currency_id'=>$cuid['currency_id']))}" method="post" action="{:U('Pay/ti_bi')}"
							class="form-inline" id="withdraw-form" method="post"
							novalidate="novalidate">
							<input name="__RequestVerificationToken" type="hidden"
								value="anYKTyhQfMR-R0Kc4_Dwcdqs5opcnQ7XnPZOw2jpaB6BVNttPcpS-cqTBqlqB3KopiKgsNUZUhgAZXpWrlbEE9kkx5nanyn01Iu0nX5hfdw52bBcDhxhzkmr3jegPM7udyyaNQ2">
							<div class="form-group">

								提币数额<input class="form-control valid" data-val="true"
									data-val-number="字段 Amount 必须是一个数字。"
									data-val-range="提币金额有误，请重新输入" data-val-range-max="1E+16"
									data-val-range-min="0" data-val-regex="提币金额有误，请重新输入"
									data-val-regex-pattern="^\d+(\.\d{1,8})?$"
									data-val-required="提币数额不能为空" id="withdraw-amount" onkeyup="limit();"
									type="text" value="0" aria-required="true" aria-invalid="false"
									aria-describedby="withdraw-amount-error"
									 name="num"> 
									实际到账 <input
									id="get-amount" type="text" class="form-control form-hover"
									disabled="" value=""> <span class="fee">（手续费{$config.tcoin_fee|mb_substr=0,4,"utf-8"}%）</span>
							</div>
							<script type='text/javascript'>
					function limit(){
					var num=$('#withdraw-amount').val();
					if(num>{$cuser.num}){
					alert("超出余额");
					$('#withdraw-amount').val("");
					
					}
					}
					function bbb(){
                    var num=$('#withdraw-amount').val();
                    var num_p=parseFloat(num);
					$('#withdraw-amount').val(num_p);
					}
					
                    
                  </script><br>
							<div class="form-group">
								交易密码 <input class="form-control input-trade" data-val="true"
									data-val-required="交易密码不能为空" id="trade-code"
									name="paypwd" type="password">
							</div>
							<div class="form-group">
								<label for="captcha">输入短信验证码</label> <input
									class="form-control captcha" data-val="true"
									data-val-required="您输入的短信验证码有误，请重新输入" id="vcode" name="code"
									type="text" value=""> 
								<input type="button" class="btn btn-success" onclick="sandPhone()" id="msgt" value="获取验证码">
							</div>
							 <input type="hidden" name="currency_id" value="{$cuid.currency_id}">
							<div class="form-group">
								<input data-val="true" data-val-number="字段 AddressId 必须是一个数字。"
									data-val-required="请选择提币地址" id="AddressId" name="AddressId"
									type="hidden" value="-1"> 
									<input id="MarketCoinId" name="MarketCoinId" type="hidden" value="DWC"> <input
									data-val="true" data-val-number="字段 Fee 必须是一个数字。"
									data-val-required="The Fee field is required." id="Fee"
									name="Fee" type="hidden" value="{$config.tcoin_fee|mb_substr=0,4,"utf-8"}"> 
									<input data-val="true" data-val-number="字段 SpecialFeeRate 必须是一个数字。"
									id="SpecialFeeRate" name="SpecialFeeRate" type="hidden"
									value="">
								
							</div>
							<br>
							<center><button id="submit" class="btn btn-primary">确认提币</button></center>
							<div class="msg">
								<span
									class="amount-msg field-validation-valid field-validation-custom-valid"
									data-valmsg-for="Amount" data-valmsg-replace="true"></span> <span
									class="field-validation-valid capital-msg"
									data-valmsg-for="CapitalPassword" data-valmsg-replace="true"></span>
								<span
									class="field-validation-valid address-msg address-msg-notice"
									data-valmsg-for="AddressId" data-valmsg-replace="true"></span>
							</div>
							 <input name="select_address" id="select_address" type="hidden" value="{$address[0]['id']}">
						</form>
					</div>
					<div class="commonnotice">
						<p>
							转出说明<br> 1、提币手续费为{$config.tcoin_fee|mb_substr=0,4,"utf-8"}%，请仔细确认后再操作。<br> <span>2、每次提币最小限额为1.00
						</p>
					</div>

					<h2>转出记录</h2>
					<table class="table" id="coin-deposit-record">
						<thead>
							<tr>
								<th>记录ID</th>
								<th>转入钱包地址</th>
								<th>转出数量</th>
								<th>实际到账</th>
								<th>操作时间</th>
								<th>状态</th>
							</tr>

						</thead>
						<tbody>
							<volist name="tibi_list" id='vo'>
								<tr id="btc_box" class="btc_new">
									<td id="btc_id">{$vo.id}</td>
									<td id="btc_wallet">{$vo.url}</td>
									<td id="btc_number">{$vo.num|number_format=###,4}</td>
									<td id="btc_fee">
									<eq name="vo.status" value="1">
										{$vo.actual}
						                <else/>
						               暂无记录
						                </eq>
										</td>
									<td id="btc_created">{$vo.add_time|date="Y-m-d H:i:s",###}</td>
									
									
									<td class="tableEnd" id="btc_status">
									<eq name="cuid.currency_name" value='比特币'>
									
									<eq name="vo.status" value="8">驳回<else/><eq name="vo.status" value="1">通过<else/>审核中</eq></eq>
									
									<else />
									<if condition="$vo.status eq 12"> 
									等待审核中
									<elseif condition="$vo.status eq 0"/>
									等待转出
									<elseif condition="$vo.status eq 1"/>
									已经到账
									<elseif condition="$vo.status eq -1"/>
									转出审核失败
									<else /> 
									未知状态
									</if>
									</eq>
									
									</td>
								</tr>
										
								</volist>
						</tbody>
					</table>
				</div>
				<div class="row new-page">
					<div class="col-sm-12 text-center">
						<ul class="pagination"></ul>
					</div>
				</div>


			</div>
		</div>
	</div>
</div>
<script>
		function address_id(_this){
						var list= $('input:radio[name="redios"]:checked').val();
						$("#select_address").val(list);
						//console.log(_this.parents('tr').children('td'));
						var add = _this.parents('tr').children('td').eq(2).children('input').val();
						//alert(add);
						$("#addre_show").html(add);
						//$("#select_address").attr('type','text');
						
					}
		</script>
<script>
$("#addressForm").validate({			   
    rules: {
        name: {
            required: true,
        },
        address: {
            required: true,
        }
    },
    messages: {
      name: {
            required: "姓名不能为空",
        },
        cardnum: {
            required: '地址不能为空',
        }
    },
	submitHandler:function(form){
		ajax_submit_form(form)
		return false;
	},
	invalidHandler: function() {  //不通过回调 
		  return false; 
	  },

});
$("#withdraw-form").validate({			   
    rules: {
        num: {
            required: true,
        },
        paypwd: {
            required: true,
        },
		code:{
			required: true,
		}
    },
    messages: {
      num: {
            required: "金额不能为空",
        },
        paypwd: {
            required: "请填写交易密码",
        },
		code: {
            required: "请填写验证码",
        }
    },
	submitHandler:function(form){
		ajax_submit_form(form)
		return false;
	},
	invalidHandler: function() {  //不通过回调 
		  return false; 
	  },

});
    $('#coin-withdraw-address').on('click', '#card-chose tbody tr', function () {
        $('#card-chose').find('tbody tr').removeClass();
        $(this).addClass('chose');
        var $radio = $(this).find('input[type=radio]');
        $radio.prop('checked', true);
        $("#AddressId").val($radio.val());
    });
    $("#coin-withdraw-address").on("click", "#addAddress", function () {
        $(".address-confirm").toggle();
        if ($("#addAddress").hasClass('add')) {
            $("#addAddress").attr('class', 'can').html('<span></span> 收起');
        } else {
            $("#addAddress").attr('class', 'add').html('<span></span> 添加一个新的提币地址');
        }
    });
    function caculateFee(num){
        var minFee = 0.0000000000000000;
        if (num == null || isNaN(num)) {
            num = 0;
        }
        //console.log($("#SpecialFeeRate").val());
        var fee = num - num / (1 + parseFloat($("#Fee").val()));
        var digitInt = Math.pow(10, 6);
        fee = Math.floor(fee * digitInt) / digitInt;
        fee = fee < minFee ? minFee : fee;

        if($("#SpecialFeeRate").val()!=null && $("#SpecialFeeRate").val()!= ''){
            var $specialFeeRate = parseFloat($("#SpecialFeeRate").val());
            fee = fee * $specialFeeRate;
            fee = Math.floor(fee * digitInt) / digitInt;
        }
        rs = (Math.floor(num * digitInt) - Math.floor(fee * digitInt)) / digitInt;
        $("#get-amount").val(rs<0?0:rs);
    }
    $(function () {
        $("#coin-withdraw-address").on("click", "input[name=card-id]", function () {
            $("#AddressId").val($(this).val());
        });
         caculateFee(parseFloat($("#withdraw-amount").val()))
         $("#withdrawDiv").on("keyup", "#withdraw-amount", function () {
             caculateFee(parseFloat($(this).val()));
         });
    });
    function sandPhone(){
        var phone="{$member.phone}";
		var i=120;
        var tid2;
        tid2=setInterval(function(){
            if($("#msgt").attr("data-key")=='off'){
                $("#msgt").attr("disabled",true);
                $("#msgt").removeClass("class");
                $("#msgt").addClass("button again");
                i--;
                $("#msgt").val(i+"秒后可重新发送");
                if(i<=0){
                    $("#msgt").removeAttr("disabled").val("重新发送验证码");
                    $("#msgt").attr("data-key","on");
                }
            }
        },1000);
            $.post("{:U('ModifyMember/ajaxSandPhone')}",{'phone':phone},
                    function(d){
                       layer.msg(d.info);
                        if(d.status==1){
                            i=120;
                            $("#msgt").attr("data-key","off");
            	 }
            });
    }  
    </script> 
<include file="App/Home/View/Public/footer.html" />